#include "ecb/benchmarks/mpb/PeakFunctionSphere.h"

#include "ecb/base/Math.h""
#include <math.h>

namespace ecb {
    namespace mpb {

        PeakFunctionSphere::PeakFunctionSphere() { }

        PeakFunctionSphere::~PeakFunctionSphere() { }

        scalar PeakFunctionSphere::f(const std::vector<scalar>& x, const Matrix2D& peaks, int peakIndex) {
            double dummy = (x[0] - peaks[peakIndex][0]) * (x[0] - peaks[peakIndex][0]);
            for (int j = 1; j < x.size(); j++) {
                dummy += Math::Pow2(x[j] - peaks[peakIndex][j]);
            }

            return peaks[peakIndex][x.size() + 1] - dummy;
        }

        std::string PeakFunctionSphere::toString() const {
            return "PeakFunctionSphere";
        }

    }
}
